package com.qys.livesMall.anchor.controller.app;


import com.qys.livesMall.anchor.model.dto.lives.app.BanUserDTO;
import com.qys.livesMall.anchor.service.LivesRoomAdminService;
import com.qys.livesMall.common.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


/**
 * 直播间管理员表(LivesRoomAdmin)表控制层
 *
 * @author makejava
 * @since 2023-09-12 10:02:05
 */
@RestController
@RequestMapping("/app/livesRoomAdmin")
@Tag(name = "App-直播间房管功能", description = "App-直播间房管功能")
public class LivesRoomAdminController {

    /**
     * 服务对象
     */
    @Resource
    private LivesRoomAdminService livesRoomAdminService;


    @Operation(summary = "主播设置/取消管理员")
    @PostMapping("/setAdmin/{userId}")
    public R<?> setAdmin(@PathVariable Long userId){
        livesRoomAdminService.setAdmin(userId);
        return R.ok();
    }


    @Operation(summary = "判断用户是否是房管", description = "userId可不传")
    @GetMapping("/isRoomAdmin/{liveRoomNumber}/{userId}")
    public R<Boolean> isRoomAdmin(@PathVariable String liveRoomNumber, @PathVariable(required = false) Long userId){
        return R.ok(livesRoomAdminService.isRoomAdmin(liveRoomNumber, userId));
    }

    @Operation(summary = "判断用户是否被禁言", description = "userId可不传")
    @GetMapping("/isForbidSendMsg/{liveRoomNumber}/{userId}")
    public R<Boolean> isForbidSendMsg(@PathVariable String liveRoomNumber, @PathVariable(required = false) Long userId){
        return R.ok(livesRoomAdminService.isForbidSendMsg(liveRoomNumber, userId));
    }

    @Operation(summary = "封禁用户(踢出房间)")
    @PostMapping("/banUser")
    public R<?> banUser(@RequestBody BanUserDTO dto){
        livesRoomAdminService.banUser(dto);
        return R.ok();
    }

    @Operation(summary = "主播设置禁言", description = "type: 0所有人可发言，1所有人禁言，2我关注的人可发言，3我的粉丝可发言")
    @PostMapping("/forbidSendMsg/{groupId}/{type}")
    public R<?> forbidSendMsg(@PathVariable Long groupId, @PathVariable Integer type){
        return R.ok(livesRoomAdminService.forbidSendMsg(groupId, type));
    }

    @Operation(summary = "查询直播间禁言状态", description = "0所有人可发言，1所有人禁言，2我关注的人可发言，3我的粉丝可发言")
    @GetMapping("/getForbidSendMsgStatus/{sessionId}")
    public R<Integer> forbidSendMsg(@PathVariable Long sessionId){
        return R.ok(livesRoomAdminService.getForbidSendMsgStatus(sessionId));
    }
}

